package pers.jsan.litheopen.security.oauth;

public class ClientContextHolder {

    private static ThreadLocal<ClientContext> contextHolder = new InheritableThreadLocal<>();

    public static ClientContext get() {
        ClientContext clientContext = contextHolder.get();
        if (clientContext == null) {
            clientContext = new ClientContext();
            contextHolder.set(clientContext);
        }
        return clientContext;
    }

    public static void set(ClientContext clientContext) {
        contextHolder.set(clientContext);
    }

    public static void clear() {
        contextHolder.remove();
    }
}
